package com.lmx.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.lmx.persistence.service.MessageService;
import com.lmx.persistence.service.RechargeService;
import com.lmx.persistence.service.UserService;
import com.lmx.repoDomain.tmodel.RechargePageInfo;

@Controller
@RequestMapping("/backStand")
public class RechargeController {

	private final Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    RechargeService rechargeService;
    
    @Autowired
    UserService userService;
    
    @Autowired
    MessageService messageSerive;
    
    @Autowired
    HttpServletRequest request;
    
    //获取充值交易流水列表
    @RequestMapping(value = "/getRechargeList", method = RequestMethod.GET)
    public String  getRechargeList(ModelMap model,RechargePageInfo rechargePageInfo) {
    	
    	Map<String ,Object> values = new HashMap<String ,Object>();
    	
    	//验证当前页数
    	if(!String.valueOf(rechargePageInfo.getPage()).isEmpty()){
    		int pageNum = (rechargePageInfo.getPage()-1)*rechargePageInfo.getSize();
    		values.put("pageNum", pageNum);
    		values.put("size", rechargePageInfo.getSize());
    		model.put("page", rechargePageInfo.getPage());
    	}else{
    		model.put("erroMessage", "参数错误");
    		return "page/erro";
    	}
    	
    	String loginName = rechargePageInfo.getLoginName();//用户名
    	values.put("loginName", loginName);
    	model.put("loginName", loginName==null?loginName="":loginName);
    	
    	String entName = rechargePageInfo.getEntName();//企业名称
    	values.put("entName", entName);
    	model.put("entName", entName==null?entName="":entName);
    	
    	String name = rechargePageInfo.getName();//姓名
    	values.put("name", name);
    	model.put("name", name==null?name="":name);
    	
    	String startTime = rechargePageInfo.getStartTime();//开始时间
    	values.put("startTime", startTime);
    	model.put("startTime", startTime==null?startTime="":startTime);
    	
    	String enTime = rechargePageInfo.getEnTime();//截止时间
    	values.put("enTime", enTime);
    	model.put("enTime", enTime==null?enTime="":enTime);
    	
    	//获取充值交易流水列表
    	List<Map<String ,Object>> rechargeList = rechargeService.getRechargeList(values);
    	//获取充值交易流水列表总条数
    	int count = rechargeService.getRechargeListCount(values);
    	
    	model.put("rechargeList", rechargeList);
    	model.put("count", count);
    	
        return "page/pay/rechargeList";
    }
    
    //获取用户列表
/*    @RequestMapping(value = "/getUserList", method = RequestMethod.GET)
    @ResponseBody
    public String  getUserList(String loginName,int page,String roleCode) {
    	String json = "";
    	Map<String ,Object> msgMap = new HashMap<String ,Object>();
    	Map<String ,Object> values = new HashMap<String ,Object>();
    	
    	//验证当前页数
    	int size = 10;
    	if(!String.valueOf(size).isEmpty()){
    		int pageNum = (page-1)*size;
    		values.put("pageNum", pageNum);
    		values.put("size", size);
    		msgMap.put("page", page);
    	}else{
    		msgMap.put("flag", 0);
    		json = CommonUtil.mapToJsonString(msgMap);
            return json;
    	}
    	
    	//用户名
    	values.put("loginName", loginName);
    	msgMap.put("loginName", loginName==null?loginName="":loginName);
    	
    	//用户类型
    	if(roleCode.isEmpty()){
    		roleCode = "'reg-customer_service','reg-enterprises'";
    	}
    	values.put("roleCode", roleCode);
    	msgMap.put("roleCode", roleCode==null?roleCode="'reg-customer_service','reg-enterprises'":roleCode);
    	
    	values.put("status", "3");
    	
    	//获取用户列表
    	List<Map<String ,Object>> userList = userService.getCompanyUserList(values);
    	//获取用户列表总条数
    	int count = userService.getUserListCount(values);
    	
    	msgMap.put("userList", userList);
    	msgMap.put("count", count);
    	msgMap.put("flag", 1);
    	
    	json = CommonUtil.mapToJsonString(msgMap);
        return json;
    }  */  
   
    
}
